{if $time_limit neq 0}
{literal}
<script type="text/javascript" language="javascript">
$(function () {
{/literal}
	var time_limit = {$time_limit};
	var seconds = 59;
	var seconds2 = 59;
{literal}
	var ntime_limit = time_limit - 1;
	/*if(seconds2 >= 0) {
		newcountdown2 = setInterval(function(){
			$('#countdown').html('<b>Time lefta: ' + ntime_limit + ' minutes ' + seconds2 + ' seconds</b>');
			if(seconds2 > 0) { seconds2--; }
			if(seconds2 == 0) {
				countdown = setInterval(function(){
					//$('#countdown').html('<b>' + (time_limit - 1) + ' minutes</b>');						 
					newcountdown = setInterval(function(){
					$('#countdown').html('<b>Time leftb: ' + (ntime_limit - 1) + ' minutes ' + seconds + ' seconds</b>');
					seconds--;
					}, 1000);
					if(ntime_limit == 0) {
						$('#btn_submit').attr("disabled", true);
						$('#countdown').html('<b>Time out.</b>');
						stop();
					}
					if(ntime_limit > 0) {
						ntime_limit--;
						seconds = 59;
					}
				}, 60000);
			}
		}, 1000);
	}*/
	$('#countdown').html('<b>Time left: ' + time_limit + ' minutes. Begin to countdown...</b>');
	countdown = setInterval(function(){
		$('#countdown').html('<b>Time left: ' + (ntime_limit - 1) + ' minutes</b>');						 
		/*newcountdown = setInterval(function(){
		$('#countdown').html('<b>Time left: ' + (ntime_limit - 1) + ' minutes ' + seconds + ' seconds</b>');
			if(seconds > 0) {
				seconds = seconds - 1;
			}
		}, 1000);*/
		if(ntime_limit == 0) {
			$('#btn_submit').attr("disabled", true);
			$('#countdown').html('<b>Time out.</b>');
			//stop();
		}
		if(ntime_limit > 0) {
			ntime_limit--;
			//seconds = 59;
		}
	}, 60000);
	
});
</script>
{/literal}
{/if}
{if $time_limit neq 0}
<div><b>Your First Attempt - Time of Test: {$time_limit} minutes</b></div><br />
<div id="countdown"></div><br />
{else}
<!--<div><input type="button" name="btn_back" value="Back" onclick="history.back(1);" /></div><br />-->
<div><b>Your First Attempt</b></div><br />
{/if}
<form name="frm_dotest" method="POST" action="">
<div>
<table border="1" width="600" cellpadding="5" cellspacing="0" style="border-collapse:collapse">
	<tr>
    	<td width="10" align="center">Number</td>
        <td width="400" align="center">Answer page</td>
    </tr>
    {section name="qa" loop=$list_questions}
    <tr>
    	<td align="center">{$smarty.section.qa.iteration}</td>
        <td>
        	<div><label><b>Question:</b><br /> {$list_questions[qa].Question}</label><input type="hidden" name="qid[]" value="{$list_questions[qa].QuestionNo}" /><input type="hidden" name="q_model[]" value="{$list_questions[qa].ModelAnswer}" /></div><br />
            <div><b><label>Answer:</label></b></div>
            {if $list_questions[qa].ModelAnswer eq 0}
            <div>
            	<input type="radio" name="answer{$smarty.section.qa.iteration}" value="1|{$list_questions[qa].Option1}" />&nbsp;{$list_questions[qa].Option1} 
                <br /><input type="radio" name="answer{$smarty.section.qa.iteration}" value="2|{$list_questions[qa].Option2}" />&nbsp;{$list_questions[qa].Option2}	
                {if $list_questions[qa].Option3}
                <br /><input type="radio" name="answer{$smarty.section.qa.iteration}" value="3|{$list_questions[qa].Option3}" />&nbsp;{$list_questions[qa].Option3}
                {/if}
                {if $list_questions[qa].Option4}
                <br /><input type="radio" name="answer{$smarty.section.qa.iteration}" value="4|{$list_questions[qa].Option4}" />&nbsp;{$list_questions[qa].Option4}
                {/if}
                {if $list_questions[qa].Option5}
                <br /><input type="radio" name="answer{$smarty.section.qa.iteration}" value="5|{$list_questions[qa].Option5}" />&nbsp;{$list_questions[qa].Option5}
                {/if}
            </div>
            {elseif $list_questions[qa].ModelAnswer eq 1}
            <div>
            	<input type="checkbox" name="answer{$smarty.section.qa.iteration}[]" value="1|{$list_questions[qa].Option1}" />&nbsp;{$list_questions[qa].Option1}
                {if $list_questions[qa].Option2}
                <br /><input type="checkbox" name="answer{$smarty.section.qa.iteration}[]" value="2|{$list_questions[qa].Option2}" />&nbsp;{$list_questions[qa].Option2}
                {/if}
                {if $list_questions[qa].Option3}
                <br /><input type="checkbox" name="answer{$smarty.section.qa.iteration}[]" value="3|{$list_questions[qa].Option3}" />&nbsp;{$list_questions[qa].Option3}
                {/if}
                {if $list_questions[qa].Option4}
                <br /><input type="checkbox" name="answer{$smarty.section.qa.iteration}[]" value="4|{$list_questions[qa].Option4}" />&nbsp;{$list_questions[qa].Option4}
                {/if}
                {if $list_questions[qa].Option5}
                <br /><input type="checkbox" name="answer{$smarty.section.qa.iteration}[]" value="5|{$list_questions[qa].Option5}" />&nbsp;{$list_questions[qa].Option5}
                {/if}
            </div>
            {elseif $list_questions[qa].ModelAnswer eq 2}
            <div>
            	<input type="text" name="answer{$smarty.section.qa.iteration}" maxlength="25" size="15" />
            </div>
            {elseif $list_questions[qa].ModelAnswer eq 3}
            <div>
            	<textarea name="answer{$smarty.section.qa.iteration}" wrap="virtual" cols="50" rows="7"></textarea>
            </div>
            {/if}
        </td>
    </tr>
    {/section}
</table>	
</div>
<br />
<input type="hidden" name="testid" value="{$testid}" />
<input type="hidden" name="attempt" value="{$attempt}" />
<input type="hidden" name="number_questions" value="{$number_questions}" />
<div align="center"><input type="submit" id="btn_submit" name="btn_submit" value="Submit" /></div>
</form>